import pandas as pd
df = pd.read_csv('merge.csv')
df['create_time'] = pd.to_datetime(df['create_time'])
df['年份'] = df['create_time'].dt.year
df['月份'] = df['create_time'].dt.month
df['季度'] = (df['月份'] - 1) // 3 + 1
kh_monthly_demands = df.groupby(['年份', '季度','hplx','khmc'])['jz'].sum()
print(kh_monthly_demands)
kh_monthly_demands.to_csv('kh_monthly_demands.csv')